package o;

import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.flv.TagPayloadReader;
import com.google.android.exoplayer2.extractor.flv.TagPayloadReader.UnsupportedFormatException;
import com.huawei.appgallery.festivalanimation.particle.modifiers.SizeModifier;

final class ael extends TagPayloadReader {
    private int ʽ;
    private boolean ˊ;
    private final anc ˋ = new anc(4);
    private int ˎ;
    private final anc ॱ = new anc(and.ˏ);

    public ael(aef o_aef) {
        super(o_aef);
    }

    public boolean ॱ(anc o_anc) throws UnsupportedFormatException {
        int ʽ = o_anc.ʽ();
        int i = (ʽ >> 4) & 15;
        ʽ &= 15;
        if (ʽ != 7) {
            throw new UnsupportedFormatException("Video format not supported: " + ʽ);
        }
        this.ʽ = i;
        return i != 5;
    }

    public void ˊ(anc o_anc, long j) throws ParserException {
        int ʽ = o_anc.ʽ();
        long ͺ = (((long) o_anc.ͺ()) * 1000) + j;
        if (ʽ == 0 && !this.ˊ) {
            anc o_anc2 = new anc(new byte[o_anc.ˊ()]);
            o_anc.ˎ(o_anc2.ˏ, 0, o_anc.ˊ());
            anw ॱ = anw.ॱ(o_anc2);
            this.ˎ = ॱ.ˎ;
            this.ˏ.ˎ(Format.ˏ(null, "video/avc", null, -1, -1, ॱ.ॱ, ॱ.ˏ, SizeModifier.STABLE_STATE_SCALE, ॱ.ˋ, -1, ॱ.ˊ, null));
            this.ˊ = true;
        } else if (ʽ == 1 && this.ˊ) {
            byte[] bArr = this.ˋ.ˏ;
            bArr[0] = (byte) 0;
            bArr[1] = (byte) 0;
            bArr[2] = (byte) 0;
            ʽ = 4 - this.ˎ;
            int i = 0;
            while (o_anc.ˊ() > 0) {
                o_anc.ˎ(this.ˋ.ˏ, ʽ, this.ˎ);
                this.ˋ.ˋ(0);
                int ʽॱ = this.ˋ.ʽॱ();
                this.ॱ.ˋ(0);
                this.ˏ.ˎ(this.ॱ, 4);
                int i2 = i + 4;
                this.ˏ.ˎ(o_anc, ʽॱ);
                i = i2 + ʽॱ;
            }
            this.ˏ.ˋ(ͺ, this.ʽ == 1 ? 1 : 0, i, 0, null);
        }
    }
}
